﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework.Graphics;

namespace Nyx.Scenes
{
    /// <summary>
    /// A container for various objects and textures that make up a simple scene.
    /// </summary>
    public class Scene
    {
        List<SceneLayer> layers = new List<SceneLayer>();
        List<SceneValue> values = new List<SceneValue>();

        /// <summary>
        /// Initializes a new instance of the <see cref="Scene"/> class.
        /// </summary>
        /// <param name="width">The width (in pixels).</param>
        /// <param name="height">The height (in pixels).</param>
        public Scene(int width, int height)
        {
            this.Width = width;
            this.Height = height;
        }

        /// <summary>
        /// Gets or sets the height of the scene (in pixels).
        /// </summary>
        /// <value>The height of the scene (in pixels).</value>
        public int Height { get; set; }

        /// <summary>
        /// Gets the layers.
        /// </summary>
        /// <value>The layers.</value>
        public IEnumerable<SceneLayer> Layers
        {
            get { return layers.AsEnumerable<SceneLayer>(); }
        }

        /// <summary>
        /// Gets the values.
        /// </summary>
        /// <value>The values.</value>
        public IEnumerable<SceneValue> Values
        {
            get { return values.AsEnumerable<SceneValue>(); }
        }

        /// <summary>
        /// Gets or sets the width of the scene (in pixels).
        /// </summary>
        /// <value>The width of the scene (in pixels).</value>
        public int Width { get; set; }

        /// <summary>
        /// Renders the scene.
        /// </summary>
        /// <param name="spriteBatch">The sprite batch.</param>
        public void Render(SpriteBatch spriteBatch)
        {
            foreach (SceneLayer layer in layers)
            {
                if (layer != null && layer.Visible)
                    layer.Render(spriteBatch);
            }
        }
    }
}
